﻿@using Vit.Common.Providers.Localization;
@model IEnumerable<JsonResource>
@{
}
<script type="text/javascript">
    function SaveLang() {
        var formId = $('#jsonLocalDiv div:visible form').attr('id');
        Submit(formId, '/Admin/JsonLocal/Save');
    }

    function DeleteLang() {
        var formId = $('#jsonLocalDiv div:visible form').attr('id');
        Delete(formId, '/Admin/JsonLocal/Delete');
    }
</script>
<div>
    <ul>
        <li><a href="/Admin/Local/Index">用户资源</a></li>
        <li><a href="/Admin/JsonLocal/Index" class="selected">系统资源</a></li>
    </ul>
</div>
@if (this.Model != null)
{
    <div id="jsonLocalDiv" class="tabs">
        <ul>
            @foreach (var lang in ViewBag.Languages)
            {
                <li><a href="#@lang">@lang</a></li>
            }
        </ul>
        @foreach (var lang in ViewBag.Languages)
        {
            <div id="@lang">
                <h3>
                    Language: @lang</h3>
                    <a href="/Admin/JsonLocal/AppendAsm/@lang" class="dialog">Append From Assembly</a>
                    <a href="/Admin/JsonLocal/Copy/@lang" class="dialog">Copy From Other Language</a>
                    <a href="/Admin/JsonLocal/AppendView/@lang">Append View Localizations</a>
                @{ Html.BeginForm("Delete", null, FormMethod.Post, new { id = lang + "-list-form", name = lang + "-list-form" });
                }
                <table id="list-table" class="list-table" cellpadding="0" cellspacing="0" border="0">
                    <thead>
                        <tr>
                            <th>
                                <input type="checkbox" onclick="if(this.checked) { $('#@lang-list-form input:checkbox').attr('checked', 'checked'); } else { $('#@lang-list-form input:checkbox').removeAttr('checked'); }" />
                            </th>
                            <th>
                                AssemblyName
                            </th>
                            <th>
                                Resource
                            </th>
                            <th>
                                Value
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var res in this.Model.Where(o => o.CultureInfoName == (lang.ToLower() == "default" ? "" : lang)))
                        {
                            foreach (var r in res.Resources)
                            {
                                var key = string.Format("{0}${1}${2}", res.AssemblyName, lang, r.Name);
                            <tr>
                                <td>
                                    <input type="checkbox" id="cb_@(key)" name="cb_@(key)" value="@key" />
                                </td>
                                <td>@res.AssemblyName
                                </td>
                                <td>@r.Name
                                </td>
                                <td><input id="@key" name="@key" type="text" value="@r.Value" />
                                </td>
                            </tr>
                            }
                        }
                    </tbody>
                </table>
                @{Html.EndForm();
                }
            </div>
        }
    </div>
}

